package com.zero.system.service.Impl;

import com.zero.system.entity.Models;
import com.zero.system.mapper.AdminMapper;
import com.zero.system.mapper.ModelsMapper;
import com.zero.system.service.ModelsService;
import com.zero.system.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
public class ModelsServiceImpl implements ModelsService {
    @Resource
    private ModelsMapper modelsMapper;

    @Override
    public PageBean<Models> queryPage(Map<String, Object> paramMap) {
        PageBean<Models> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));
        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Models> datas = modelsMapper.queryList(paramMap);
        pageBean.setDatas(datas);
        Integer totalsize = modelsMapper.getCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public Integer getCount(Map<String, Object> paramMap) {
        return modelsMapper.getCount(paramMap);
    }

    @Override
    public int add(Models models) {
        return modelsMapper.add(models);
    }

    @Override
    public Models findById(Integer id) {
        return modelsMapper.findById(id);
    }

    @Override
    public int delete(List<Integer> ids) {
        return modelsMapper.delete(ids);
    }

    @Override
    public int update(Models models) {
        return modelsMapper.update(models);
    }

    @Override
    public Models findByModelsNo(String modelsNo) {
        return modelsMapper.findByModelsNo(modelsNo);
    }

    @Override
    public List<Models> findAll() {
        return modelsMapper.findAll();
    }

    @Override
    public List<Models> findByCompanyId(int companyId) {
        return modelsMapper.findByCompanyId(companyId);
    }
}
